home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _4B643AD778654343ACA546F3F0732608 < prev    next >
Encoding:
Text File  |  2004-01-06  |  1.4 KB  |  44 lines

  1. // ===============================================================
  2. // Vertex Program: 
  3. // Description: 
  4. // Last Update: 14/08/2003
  5. // Coder: Andrey Honich
  6. // ===============================================================
  7.  
  8.       #include "../CGVPMacro.csi"
  9.  
  10.  
  11.       VertAttributes { POSITION_3 TEXCOORD0_2 TANG_3X3 }
  12.       MainInput { VIEWPROJ_MATRIX, LIGHT_POS, CAMERA_POS, ATTEN }
  13.       DeclarationsScript
  14.       {
  15.         IN_T0_TANG
  16.         OUT_T0_T1_C0_C1
  17.       }
  18.       PositionScript = PosCommon
  19.       CoreScript
  20.       {
  21.         OUT.Tex0.xy = IN.TexCoord0.xy;
  22.         OUT.Tex1.xy = IN.TexCoord0.xy;
  23.  
  24.         TANG_MATR
  25.  
  26.         // store normalized light vector
  27.         float3 lightVec = LightPos.xyz - vPos.xyz;
  28.         float fiSqDist = rsqrt(dot(lightVec,lightVec));
  29.         lightVec = lightVec * fiSqDist;
  30.         OUT.Color.w = PROC_ATTENVERT;
  31.  
  32.         // transform light vector from object space to tangent space and pass it as a color
  33.         OUT.Color.xyz = 0.5 * mul(objToTangentSpace, lightVec.xyz) + 0.5.xxx;
  34.  
  35.         // compute view vector
  36.         float3 viewVec = normalize(CameraPos.xyz - vPos.xyz);
  37.  
  38.         // compute half angle vector
  39.         float3 halfAngleVector = normalize(lightVec.xyz + viewVec);
  40.  
  41.         // transform half angle vector from object space to tangent space and pass it as a color
  42.         OUT.Color1.xyz = 0.5 * mul(objToTangentSpace, halfAngleVector) + 0.5.xxx;
  43.       }
  44.